<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>map和reduce</title>
</head>
<body>
<script>
    let arr =[6,5,4,3,2,1]
    let result = arr.reduce((pre, cur)=>pre+cur);
    console.log(result)


    let  cratArr =[
        {
            id:10001,
            price:20,
            num:6
        },
        {
            id:10002,
            price:30,
            num:2
        },
        {
            id:10003,
            price:40,
            num:5
        },
    ]

    let number = cratArr.map(ele=>ele.price*ele.num).reduce((pre, cru)=>pre+cru);
    console.log(number)
</script>
</body>
</html>